<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <script src="__PUBLIC__/js/jquery-1.9.0.js"></script>
    <script src="__PUBLIC__/js/angular.js"></script>
    <script src="__PUBLIC__/home/plugins/layer/layer.js"></script>
    <!--标准mui.css-->
    <link rel="stylesheet" href="__PUBLIC__/mui/css/mui.css"/>
    <!--App自定义的css-->
    <link rel="stylesheet" href="__PUBLIC__/css/app.css"/>
    <link rel="stylesheet" href="__PUBLIC__/css/agencenter.css"/>
    <script src="__PUBLIC__/common.js"></script>
</head>
<style>
    .announce {
        background: #ffefd4;
    }

    .top_notice {
        position: absolute;
        height: 30px;
        line-height: 30px;
        text-indent: 15px;
        color: #f96230;
    }

    .top_notice_img {
        height: 30px;
        width: 30px;
        background: url("__PUBLIC__/images/btn_close.png") no-repeat center;
        background-size: auto 50%;
        position: absolute;
        right: 5px;
    }

    .marque li {
        height: 30px;
        line-height: 30px;
        list-style: none;
        color: #f96230;
        text-indent: 20px;
    }
</style>
<body ng-app="myApp" ng-controller="Ctrl" ng-cloak>


<!--header-->
<header class="mui-bar mui-bar-nav" style="height: 145px;">
    <!-- <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>-->
    <div class="user-icon mui-pull-left mui-col-xs-3">
        <img class="media-object " src="__PUBLIC__/images/lehui_app_logo_60.png"/>
    </div>
    <div class="mui-media-body user-info mui-pull-left mui-col-xs-7">
        <p class="mui-ellipsis money">{{message.name}}</p>
        <p class="mui-ellipsis money">{{message.account}}</p>
        <p class="mui-ellipsis money">可提现金额:{{message.balance}}</p>
    </div>
    <div class="user-enter mui-pull-left mui-col-xs-2">
        <a href="{:U('agen/ageninfo')}" style="width: 100%;height: 100%;display: block"></a>
    </div>
</header>


<div style="height: 145px"></div>
<div style="height: 30px;width: 100%;position: relative;overflow: hidden;font-size: 16px;" class="announce"
     ng-controller="noticeCtrl" ng-cloak>
    <div class="top_notice">公告:</div>
    <ul class="marque" style="position: absolute;margin-top: 0">
        <li ng-repeat="no in notice" ng-show="no.type == 1" ng-click="gonggao(no.id)">{{no.title}}</li>
    </ul>
    <div class="top_notice_img"></div>
</div>
<script type="text/javascript">
    $(".top_notice_img").click(function () {
        $(".announce").hide(500);
    })
    function autoScroll(obj) {
        $(obj).animate({
            marginTop: "-30px"
        }, 1000, function () {
            $(this).css({marginTop: "0px"}).find("li:first").appendTo(this);
        })
    }
    $(function () {
        setInterval('autoScroll(".marque")', 2000);
        /*调整滚动速度*/
    })
</script>

<!--banner-->
<div class="mui-content user" style="padding-top: 0px;">
    <ul class="mui-table-view mui-grid-view mui-grid-9 item" style="margin-top: 0; ">

        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/audit')}">
            <div class="user-bg logo13"></div>
            <div class="mui-media-body " style="font-size:12px;">
                代理审核
            </div>
        </a></li>
        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/agenhistroy')}">
            <div class="user-bg logo9"></div>
            <div class="mui-media-body" style="font-size:12px;">
                流转记录
            </div>
        </a></li>

        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 invite"><a href="{:U('agen/kucun')}">
            <div class="user-bg logo1"></div>
            <div class="mui-media-body" style="font-size:12px;">
                库存
            </div>
        </a></li>

        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3"><a href="{:U('agen/nextagent')}">
            <div class="user-bg logo2"></div>
            <div class="mui-media-body" style="font-size:12px;">
                下级代理
            </div>
        </a></li>
        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3"><a href="{:U('agen/mycustom')}">
            <div class="user-bg logo3"></div>
            <div class="mui-media-body" style="font-size:12px;">
                我的客户
            </div>
        </a></li>

        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/orderup')}">
            <div class="user-bg logo6"></div>
            <div class="mui-media-body " style="font-size:12px;">
                申请升级
            </div>
        </a></li>
        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/withdraw')}">
            <div class="user-bg logo7"></div>
            <div class="mui-media-body " style="font-size:12px;">
                提现管理
            </div>
        </a></li>


        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/mylist')}">
            <div class="user-bg logo10"></div>
            <div class="mui-media-body " style="font-size:12px;">
                会员订单
            </div>
        </a></li>
        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/cardlist')}">
            <div class="user-bg logo11"></div>
            <div class="mui-media-body " style="font-size:12px;">
                银行卡
            </div>
        </a></li>
        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/fanyong')}">
            <div class="user-bg logo12"></div>
            <div class="mui-media-body " style="font-size:12px;">
                返佣
            </div>
        </a></li>

        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/apikey')}">
            <div class="user-bg logo14"></div>
            <div class="mui-media-body " style="font-size:12px;">
                我的授权
            </div>
        </a></li>

        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/agentuiguang')}">
            <div class="user-bg logo15"></div>
            <div class="mui-media-body " style="font-size:12px;">
                推广二维码
            </div>
        </a></li>

        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/proxyme')}">
            <div class="user-bg logo16"></div>
            <div class="mui-media-body " style="font-size:12px;">
                销售数量
            </div>
        </a></li>
        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3"><a href="{:U('agen/address')}">
            <div class="user-bg logo4"></div>
            <div class="mui-media-body" style="font-size:12px;">
                收货地址
            </div>
        </a></li>


        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="{:U('agen/alertpassword')}">
            <div class="user-bg logo5"></div>
            <div class="mui-media-body" style="font-size:12px;">
                密码修改
            </div>
        </a></li>
        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3"><a href="{:U('agen/gonggao')}">
            <div class="user-bg logo17"></div>
            <div class="mui-media-body" style="font-size:12px;">
                公告
            </div>
        </a></li>


        <li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3 "><a href="javascript:void(0)"
                                                                                ng-click="exit()">
            <div class="user-bg logo18"></div>
            <div class="mui-media-body " style="font-size:12px;">
                退出登录
            </div>
        </a></li>
    </ul>
</div>
<div style="height: 50px"></div>

<script src="__PUBLIC__/mui/js/mui.min.js"></script>
<!--footer-->
<include file="./Application/Home/View/pub/agentfoot.html" name="m"/>

<script>
    mui.init({
        swipeBack: true //启用右滑关闭功能
    });
    var slider = mui("#slider");
    slider.slider({
        interval: 1500
    });

    var app = getApp('myApp', []);

    app.controller('Ctrl', function ($scope, $http) {
        $scope.wxflg = 0;
        $scope.code = getUrlParam('code');
        //非空，微信登录
        if ($scope.code != null && $scope.code != '') {
            $http({
                method: 'GET',
                url: "/index.php/Home/login/wxAgenLogin?code=" + $scope.code
            }).then(function successCallback(response) {
                //console.log(response.data)
                if (response.data.code == -1) {
                    layer.msg(response.data.msg.msg, {time: 1000})
                    setTimeout(function () {
                        window.location.href = "/index.php/Home/index/login";
                    }, 1000)
                } else if (response.data.code == 0) {
                    layer.msg(response.data.data.msg, {time: 1000});
                    $scope.wxflg = 1;
                }
            }, function errorCallback(response) {
                errorHandle(response);
            });
        }

        if ($scope.wxflg == 0) {
            $http({
                method: 'GET',
                url: "/index.php/Home/Agen/getAgenInfo"
            }).then(function successCallback(response) {
                //console.log(response.data);
                if (response.data.code == -1) {
                    layer.msg(response.data.msg, {time: 1000});
                    setTimeout(function () {
                        window.location.href = "/index.php/Home/index/login";
                    }, 1500)
                } else {
                    $scope.message = response.data.data.message;
                    if ($scope.message.agenurl == false) {
                        $scope.message.agenurl = '';
                    }
                    if ($scope.message.name == null) {
                        $scope.message.name = '';
                    }
                    if ($scope.message.webchat == null) {
                        $scope.message.webchat = '';
                    }
                    $scope.message.account = $scope.message.account.replace($scope.message.account.substring(3, 7), "****");
                }
            }, function errorCallback(response) {
            })
        }

        $scope.exit = function () {
            var btnArray = ['否', '是'];
            mui.confirm('', '退出登录？', btnArray, function (e) {
                if (e.index == 1) {

                    $http({
                        method: 'POST',
                        data: {id: $scope.$id},
                        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                        transformRequest: function (obj) {
                            var str = [];
                            for (var p in obj) {
                                str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                            }
                            return str.join("&");
                        },
                        url: "/index.php/Home/Login/exitlogin"
                    }).then(function successCallback(response) {
                        //console.log(response)
                        if (response.data.code == -1) {
                            layer.msg(response.data.msg, {time: 1000})
                        }
                        else if (response.data.code == 0) {
                            layer.msg("退出成功", {time: 1000})
                            setTimeout(function () {
                                window.location.href = "/index.php/Home/index/login"
                            }, 1500)
                        }

                    }, function errorCallback(response) {

                    });
                } else {
                    layer.msg("取消", {time: 1000})
                }

            })
        }
    })

    // 公告
    app.controller('noticeCtrl', function ($scope, $http) {
        $http({
            method: 'POST',
            url: "/index.php/Home/Agen/notice"
        }).then(function successCallback(response) {
            successHandle(response, function (data) {
                $scope.notice = [];
                // 存放会员公告
                for (var i in data) {
                    if (data[i].type == 1) {
                        $scope.notice.push(data[i]);
                    }
                }
            });
        }, function errorCallback(response) {
            errorHandle(response);
        });
        $scope.gonggao = function (id) {
            window.location.href = "/index.php/Home/Index/articlectn?id=" + id;
        }
    });
</script>
</body>
</html>